package juc.countdownlatch;

import java.util.concurrent.CountDownLatch;

/**
 * BOSS线程
 */
public class BossThread extends Thread {
	
	private CountDownLatch countDownLatch;
	
	BossThread(CountDownLatch countDownLatch) {
		this.countDownLatch = countDownLatch;
	}
	
	@Override
	public void run() {
		System.out.println(System.currentTimeMillis() + "\t BOSS到达会议室 " + "，但是还有" + countDownLatch.getCount() + "个员工没到。");
		
		// boss等待
		try {
			countDownLatch.await(); // 阻塞等待
//			countDownLatch.await(3, TimeUnit.SECONDS); // 超时等待
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		// 所有人都到齐了之后，BOSS的动作，该动作在会议开始之前，会被阻塞
		System.out.println(System.currentTimeMillis() + "\t 所有人都到齐了，开始开会");
	}

}
